<template>
	<div class="page">
		<c-title :hide="false" text="易货分类"></c-title>
		<div class="content">
			<div class="list" v-for="(item,index) in list" :key="index" @click="gosp(item)">
				
				<div class="l_img">
					<img :src="item.thumb" alt="">
				</div>
				<div class="r">
					<div class="name">
						{{item.store_name}}
					</div>
					<div class="address">
						{{item.address}}
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {Toast} from 'vant'
	export default{
		data(){
			return{
				id:'',
				city:'',
				list:[]
			}
		},
		activated() {
		console.log(this.$route.query)
		// this.fun
		//   .getLocation()
		//   .then(res => {
		// 	console.log(res)
		//     this.city = res.city;
		//   })
		//   .catch(err => {
		//     console.log(err);
		//   });
		this.id = this.$route.query.id
		this.getlist()
		},
		methods:{
			gosp(item){
				this.$router.push(this.fun.getUrl("yhcatelist", { store_id: item.id, fromHome: 1,store_name:item.store_name,thumb:item.thumb }));
			},
			getlist(){
				$http
					.post("plugin.store-yihuo.frontend.store.yihuo.get-store-list-by-category-id", {
						category_id:this.id,
						lng: '',
						lat: '',
						city_name:''
					})
					.then(response => {
						console.log(response)
						if (response.result === 1) {
							this.list = response.data.store_list
						} else {
							Toast(response.msg);
						}
					})
					.catch(error => {
						console.log(error);
					});
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.page{
		.content{
			.list{
				display: flex;
				padding: 0.5rem;
				background-color: #fff;
				margin-bottom: 0.2rem;
				.r{
					text-align: left;
					color: #ccc;
					.name{
						font-weight: 600;color: #000;
					}
				}
				.l_img{
					margin-right: 1rem;
					
					img{
						width: 4rem;
						height: 4rem;
					}
				}
			}	
		}
	}
</style>